﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CML.Grammer;

namespace Cml.UnitTests.Grammer
{
	[TestClass]
	public class PropertiesParserTests
	{
		[TestMethod]
		public void Test1()
		{
			try
			{
				var p = new PropertiesParser();
				var s = CML.Resources.Resource.GetResource("CML.Samples.Properties.test1.properties");
				var l = p.Parse(s);
				Assert.AreEqual(11, l.Count);
				Assert.AreEqual("test", l[0].key);
				Assert.AreEqual("val1", l[0].value);
				Assert.AreEqual("Truth1", l[1].key);
				Assert.AreEqual("Beauty", l[1].value);
				Assert.AreEqual("Truth2", l[2].key);
				Assert.AreEqual("Beauty", l[2].value);
				Assert.AreEqual("Truth3", l[3].key);
				Assert.AreEqual("Beauty", l[3].value);
				Assert.AreEqual("test2", l[4].key);
				Assert.AreEqual("val2", l[4].value);
				Assert.AreEqual("test3", l[5].key);
				Assert.AreEqual("", l[5].value);
				Assert.AreEqual("test=4", l[6].key);
				Assert.AreEqual("val:4", l[6].value);
				Assert.AreEqual("test:5", l[7].key);
				Assert.AreEqual("val=5", l[7].value);
				Assert.AreEqual("test 6", l[8].key);
				Assert.AreEqual("val 6", l[8].value);
				Assert.AreEqual("fruits", l[9].key);
				Assert.AreEqual("apple, banana, pear, cantaloupe, watermelon, kiwi, mango", l[9].value);
				Assert.AreEqual("cheeses", l[10].key);
				Assert.AreEqual("", l[10].value);
				
			}
			catch (Exception x)
			{
				throw x;
			}
		}
	}
}
